﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VatTuDTO;
using VatTuBUS1;

namespace CungUngXayDung
{
    public partial class DangNhap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
         
        }
        protected void btn_signin_Click(object sender, EventArgs e)
        {
            lbl_thongbao.Text = "";
            NguoiDungDTO dto = new NguoiDungDTO();
            string TenDangNhap = txt_user1.Text.ToString();
            string MatKhau = txt_pass1.Text.ToString();
            NguoiDungBUS nd = new NguoiDungBUS();
            dto = nd.SelectNguoiDung(TenDangNhap, MatKhau);
            if (TenDangNhap != "" || MatKhau != "")
                if (dto != null)
                {
                         Session["MaNguoiDung"] = dto.MaNguoiDung;
                          Session["TenNguoiDung"] = dto.TenNguoiDung;
                        Session["TenDangNhap"] = dto.TenDangNhap;
                        Session["MatKhau"] = dto.MatKhau;
                        Session["MaLoaiNguoiDung"] = dto.MaLoaiNguoiDung;
                        lbl_thongbao.Text =Session["HoTenKhachHang"] + " đăng nhập thành công ";
                       
                           Response.Redirect("~/"+Session["LuuURL"]);
                }
                else
                    lbl_thongbao.Text = "mat khau hoac password chua dung";
            else
                lbl_thongbao.Text = "mat khau hoac password khong duoc rong";
        }
        protected void btn_dangKy_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/DangKy.aspx");
        }
     
    }
}